﻿$(function () {
    $.ajax({
        type: "get",
        url: ApiUrl + "api/Dictionary/GetHouseTypeList",
        data: {
            Dmenuid: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
        },
        async: false,
        success: function (data, status) {
            if (status == "success") {
                $("option").remove();
                $(data).each(function (i, obj) {
                    $(obj).each(function (j, item) {
                        switch (item.Dmenuid) {
                            case 1:
                                $("#C_closeID").append("<option  value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 2:
                                $("#T_TrafficID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 3:
                                $("#T_NatureID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 4:
                                $("#T_DwellingID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 5:
                                $("#T_InfrastructureID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 6:
                                $("#T_SupportingID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 7:
                                $("#T_CloseID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 8:
                                $("#T_BuildingID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 9:
                                $("#T_TrafficID").append("<option  value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 10:
                                $("#T_AfforestID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 11:
                                $("#T_VolumeID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 12:
                                $("#T_StallID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 13:
                                $("#T_PropertyID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 14:
                                $("#T_StructureID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 15:
                                $("#T_TypesID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 16:
                                $("#T_FacadeID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 17:
                                $("#T_CommonalityID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 18:
                                $("#T_ElevatorID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 19:
                                $("#T_SupplyID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 20:
                                $("#T_WaterID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 21:
                                $("#T_HeatingID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 22:
                                $("#T_EntranceID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 23:
                                $("#T_OrientationID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 24:
                                $("#T_ResidenceID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 25:
                                $("#T_DrawingID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 26:
                                $("#C_propertyID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            //case 27:
                            //    $("#C_sourceID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                            //    break;
                            case 28:
                                $("#T_HabitableID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 29:
                                $("#T_ToiletID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 30:
                                $("#T_KitchenID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break;
                            case 31:
                                $("#T_SurroundID").append("<option value=" + item.DictionaryID + ">" + item.DictionaryName + "</option>")
                                break; 
                        }
                    })
                })
            }
        },
        error: function (e) {
        },
        complete: function () {
        }
    })
})

$(function () {
    var uri = document.location.search;//接收页面传值
    var i = uri.lastIndexOf("?") + 1;//获取问号前面的值
    var substrid = uri.substr(i);//截取问号前面的值

    //根据报告号判断小区有没有以前填写的数据如果有回填
    $.ajax({
        type: "get",
        url: ApiUrl + "api/Community/SelectByid",
        data: { P_ReportNumber: substrid },
        async: false,
        success: function (data, status) {
            if (status == "success") {
                if (data != null) {
                    $("#T_ReportNumber").val(data.T_ReportNumber)
                    $("#T_Project").val(data.T_Project)
                    $("#T_SourceID").val(data.T_SourceID)
                    $("#T_CloseID").val(data.T_CloseID)
                    $("#T_BuildingID").val(data.T_BuildingID)
                    $("#T_TrafficID").val(data.T_TrafficID)
                    $("#T_AfforestID").val(data.T_AfforestID)
                    $("#T_VolumeID").val(data.T_VolumeID)
                    $("#T_StallID").val(data.T_StallID)
                    $("#T_PropertyID").val(data.T_PropertyID)
                    $("#T_Else").val(data.T_Else)
                  //  $("#C_state").val(data.C_state)
                }
            }
        },
        error: function (e) {
            layer.msg('服务器链接超时!', { icon: 2, time: 5000 });
        },
        complete: function () {

        }
    })
    //根据报告号判断抵押物区位状况有没有以前填写的数据如果有回填
    $.ajax({
        type: "get",
        url: ApiUrl + "api/Zone/selectbyid",
        data: { P_ReportNumber: substrid },
        async: false,
        success: function (data, status) {
            if (status == "success") {
                if (data != null) {
                    $("#T_ReportNumber      ").val(data.T_ReportNumber)
                    $("#T_Master          ").val(data.T_Master)
                    $("#T_South            ").val(data.T_South)
                    $("#T_Western         ").val(data.T_Western)
                    $("#T_North            ").val(data.T_North)
                    $("#T_TrafficID       ").val(data.T_TrafficID)
                    $("#T_Traffic           ").val(data.T_Traffic)
                    $("#T_NatureID         ").val(data.T_NatureID)
                    $("#T_Nature           ").val(data.T_Nature)
                    $("#T_DwellingID         ").val(data.T_DwellingID)
                    $("#T_Dwelling          ").val(data.T_Dwelling)
                    $("#T_InfrastructureID  ").val(data.T_InfrastructureID)
                    $("#T_SupportingID     ").val(data.T_SupportingID)
                    $("#T_Explain          ").val(data.T_Explain)
                    $("#T_Infrastructure    ").val(data.T_Infrastructure)
                  //  $("#Z_state").val(data.Z_state)
                }
            }
        },
        error: function (e) {
            layer.msg('服务器链接超时!', { icon: 2, time: 5000 });
        },
        complete: function () {

        }
    })
    //根据报告号判断户内部分有没有以前填写的数据如果有回填
    $.ajax({
        type: "get",
        url: ApiUrl + "api/Indoor/SelectByid",
        data: { P_ReportNumber: substrid },
        async: false,
        success: function (data, status) {
            if (status == "success") {
                if (data != null) {
                    $("#T_purposeID").val(data.T_purposeID);
                    $("#T_Floor").val(data.T_Floor);
                    $("#T_Storey").val(data.T_Storey);
                    $("#T_OrientationID").val(data.T_OrientationID);
                    $("#T_ResidenceID").val(data.T_ResidenceID);
                    $("#T_SeveralBedroom").val(data.T_SeveralBedroom);
                    $("#T_Severaldrawing").val(data.T_Severaldrawing);
                    $("#T_Severalbathroom").val(data.T_Severalbathroom);
                    $("#T_SeveralKITCHEN").val(data.T_SeveralKITCHEN);

                    $("#T_Severalbalcony").val(data.T_Severalbalcony);//阳台
                    $("#T_SeveralTerrace").val(data.T_SeveralTerrace);//露台
                    $("#T_SeveralSmall").val(data.T_SeveralSmall);//小院
              


                    $("#T_DrawingID").val(data.T_DrawingID);
                    $("#T_Roomdescribe").val(data.T_Roomdescribe);
                    $("#T_HabitableID").val(data.T_HabitableID);
                    $("#T_Habitable").val(data.T_Habitable);
                    $("#T_ToiletID").val(data.T_ToiletID);
                    $("#T_Toilet").val(data.T_Toilet);
                    $("#T_KitchenID").val(data.T_KitchenID);
                    $("#T_Kitchen").val(data.T_Kitchen);
                    $("#T_Explain").val(data.T_Explain);
                    //$("#I_state").val(data.I_state);
                    //$("#I_Buildingafew").val(data.I_Buildingafew);
                }
            }
        },
        error: function (e) {
            layer.msg('服务器链接超时!', { icon: 2, time: 5000 });
        },
        complete: function () {

        }
    })

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
    ////根据报告号显示询价记录表信息
    //$.ajax({
    //    type: "get",
    //    url: ApiUrl + "api/InquiryRecord/Selectbyid",
    //    data: { P_ReportNumber: substrid },
    //    async: false,
    //    success: function (data, status) {
    //        if (status == "success") {
    //            if (data != "") {
    //                $(data).each(function (i, item) {
    //                    $("#tbodys").empty();
    //                    $("#P_proposal").empty();
    //                    $("#P_proposal").html(data[0].P_proposal);
    //                    $("#t_date").empty();
    //                    $("#t_date").html(data[0].t_date);
    //                    var tr = '<tr class="text-c"><td>' + item.P_ReportNumber + '</td><td colspan="2">' + item.t_iname + '</td><td>' + item.t_date + '</td></tr>';
    //                    $("#tbodys").append(tr);
    //                })
    //            }
    //            else {

    //                $("#tbodys").empty();
    //                $("#P_proposal").empty();
    //                $("#P_proposal").html("暂无");
    //                $("#t_date").empty();
    //                $("#t_date").html("暂无");

    //                var tr = '<tr class="text-c"><td>暂无</td><td colspan="2">暂无</td><td>暂无</td></tr>';
    //                $("#tbodys").append(tr);
    //            }



    //        }

    //    },
    //    error: function (e) {
    //        layer.msg('服务器链接超时!', { icon: 2, time: 5000 });
    //    },
    //    complete: function () {


    //    }
    //})


    //根据报告号判断建筑公共部位状况有没有以前填写的数据如果有回填
    $.ajax({
        type: "get",
        url: ApiUrl + "api/Facility/SelectByid",
        data: { P_ReportNumber: substrid },
        async: false,
        success: function (data, status) {
            if (status == "success") {
                if (data != null) {
                    $("#T_Buildingafew  ").val(data.T_Buildingafew)
                    $("#T_Location  ").val(data.T_Location)
                    $("#T_LocationAddress  ").val(data.T_LocationAddress)
                    $("#T_StructureID  ").val(data.T_StructureID)
                    $("#T_TypesID      ").val(data.T_TypesID)
                    $("#T_FacadeID     ").val(data.T_FacadeID)
                    $("#T_CommonalityID").val(data.T_CommonalityID)
                    $("#T_ElevatorID   ").val(data.T_ElevatorID)
                    $("#T_SupplyID     ").val(data.T_SupplyID)
                    $("#T_WaterID      ").val(data.T_WaterID)
                    $("#T_HeatingID    ").val(data.T_HeatingID)
                    $("#T_EntranceID   ").val(data.T_EntranceID)
                    $("#T_Else         ").val(data.T_Else)
                }
            }
        },
        error: function (e) {
            layer.msg('服务器链接超时!', { icon: 2, time: 5000 });
        },
        complete: function () {

        }
    })
    //基本信息的显示
    $.ajax({
        type: "get",
        url: ApiUrl + "api/Personal/selectbyP_ReportNumber",
        data:
            {
                P_ReportNumber: substrid
            },
        async: false,
        success: function (data, status) {
            if (status == "success") {
                $("#T_ReportNumber").val(data.T_ReportNumber)
                $("#T_Linkman").val(data.T_Linkman)
                $("#T_Phone").val(data.T_Phone)
                $("#T_Loanyear").val(data.T_Loanyear)
                $("#T_Loanlimit").val(data.T_Loanlimit)
                $("#T_Actual").val(data.T_Actual)
                $("#T_Located").val(data.T_Located)
                $("#T_PurposeID").val(data.T_PurposeID)
                $("#T_Activate").val(data.T_Activate)
                $("#T_ReportID").val(data.T_ReportID)
                $("#T_Assess").val(data.T_Assess)
                $("#T_DepartmentID").val(data.T_DepartmentID)
                $("#T_SiteSurveyid").val(data.T_SiteSurveyid)
                //if (data.S_idname == null || data.S_idname == 0) {
                //    $("#S_id").val("暂无")

                //}
                $("#T_Iid").val(data.T_Iid);
                $("#T_Date").val(data.T_Date)
                $("#T_State").val(data.T_State)
            }
        },
        error: function (e) {
            layer.msg('服务器链接超时!', { icon: 2, time: 5000 });
        },
        complete: function () {

        }
    })




})








